package com.zzptc.zzj.a121huatu;

import android.graphics.Color;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import org.w3c.dom.Entity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class FirstFragment extends Fragment {

    public FirstFragment() {
        // Required empty public constructor
    }


    public static FirstFragment newInstance(String param1, String param2) {
        FirstFragment fragment = new FirstFragment();
        Bundle args = new Bundle();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_first, container, false);
        //实例化控件
        LineChart lineChart = view.findViewById(R.id.line_Chart);
        ArrayList<Entry> list=new ArrayList<>();
        list.add(new Entry(1,3));
        list.add(new Entry(2,8));
        list.add(new Entry(3,6));
        list.add(new Entry(4,3));
        list.add(new Entry(5,5));
        ArrayList<Entry> list1=new ArrayList<>();
        list1.add(new Entry(1,6));
        list1.add(new Entry(2,9));
        list1.add(new Entry(3,4));
        list1.add(new Entry(4,7));
        list1.add(new Entry(5,2));
        LineDataSet lineDataSet=new LineDataSet(list,null);
        lineDataSet.setColor(Color.BLUE);
        LineDataSet lineDataSet1=new LineDataSet(list1,null);
        lineDataSet.setColor(Color.RED);

        ArrayList<ILineDataSet> lineData2=new ArrayList<>();
        lineData2.add(lineDataSet);
        lineData2.add(lineDataSet1);
        LineData lineData=new LineData(lineData2);
        // LineData lineData1=new LineData(lineDataSet1);
        lineChart.setData(lineData);

        lineChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);//BOTTOM下
        lineChart.getAxisRight().setEnabled(false);
        lineChart.getDescription().setEnabled(false);//隐藏英文单词\

        XAxis xAxis=lineChart.getXAxis();
        return view;
    }

}
